#!/sbin/openrc-run

description="Enables process accounting."

depend() {
	keyword -prefix -lxc -docker
}

: ${acct_dir:=${ACCTDIR:-/var/log/account}}
: ${acct_file:=${ACCTFILE:-pacct}}


start() {
	if [ ! -d "$acct_dir" ]; then
		mkdir -p $acct_dir
		chmod 770 $acct_dir
	fi
	if [ ! -f "$acct_dir/$acct_file" ]; then
		touch $acct_dir/$acct_file
		chmod 770 $acct_dir/$acct_file
	fi

	ebegin "Enabling process accounting"
	accton on >/dev/null
	eend $?
}

stop() {
	ebegin "Disabling process accounting"
	accton off
	eend $?
}
